﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Kaskelot.Services.Model;

namespace Stockholm.SOA.Kaskelot.WCF.ServiceImplementation.Mapping
{
    public static class BlankettFaltExtensions
    {
        public static DataContracts.BlankettFalt ToContract(this BlankettFalt entity)
        {
            DataContracts.BlankettFalt b = new DataContracts.BlankettFalt();

            CopyFromEntity(entity, b, false);

            return b;
        }

        public static DataContracts.BlankettFalt ToMinimalContract(this BlankettFalt entity)
        {
            DataContracts.BlankettFalt b = new DataContracts.BlankettFalt();

            CopyFromEntity(entity, b, true);

            return b;
        }

        public static BlankettFalt ToEntity(this DataContracts.BlankettFalt b)
        {
            BlankettFalt entity = new BlankettFalt();

            CopyToEntity(b, entity);

            return entity;
        }

        public static void UpdateEntity(this BlankettFalt entity, DataContracts.BlankettFalt blankett)
        {
            CopyToEntity(blankett, entity);
        }

        private static void CopyFromEntity(BlankettFalt from, DataContracts.BlankettFalt to, bool minimal)
        {
            to.Id = from.Id;
            to.ValId = from.ValId;
            to.BlankettId = from.BlankettId;
            to.FaltId = from.FaltId;
            to.RadIndex = from.RadIndex;
            return;
        }

        private static void CopyToEntity(DataContracts.BlankettFalt from, BlankettFalt to)
        {
            to.Id = from.Id;
            to.ValId = from.ValId;
            to.BlankettId = from.BlankettId;
            to.FaltId = from.FaltId;
            to.RadIndex = from.RadIndex;
        }
    }
}
